package text;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet("/register.do")
public class demo6Servlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setContentType("text/html; charset=UTF-8");

        String username = req.getParameter("username");
        String password = req.getParameter("password");

        if (username != null && !username.isEmpty() && password != null && password.length() >= 8) {
            resp.getWriter().println("注册成功！");
            resp.sendRedirect("html/success.html");
        } else {
            resp.getWriter().println("注册失败，用户名或密码无效！");
            req.getRequestDispatcher("html/error.html").forward(req, resp);
        }
    }
}

